package service

import (
	"singo/model"
	"singo/serializer"
)

// DefectShowService 缺陷详情的服务
type DefectShowService struct {
}

// DefectShow 缺陷
func (service *DefectShowService) DefectShow(uid string) serializer.Response {
	var defect model.Defect
	err := model.DB.First(&defect, "uid = ?", uid).Error
	if err != nil {
		return serializer.Response{
			Status: 404,
			Msg:    "缺陷不存在",
			Error:  err.Error(),
		}
	}

	return serializer.Response{
		Data: serializer.BuildDefect(defect),
	}
}
